#include "cputest.h"

// clock count base (20+1)
TEST(test301, \
	"l_%=: \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"movd %%ecx, %%mm0 \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"loop l_%= \n\t" \
     )

// if you move mmx ops closer then clock count increases by 1 for every nop skipped
TEST(test302a, \
	"l_%=: \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"movd %%ecx, %%mm0 \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"movd %%mm0, %%eax \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"loop l_%= \n\t" \
     )

// if you move mmx ops closer then clock count increases by 1 for every nop skipped
TEST(test302b, \
	"l_%=: \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"pinsrw $0, %%ecx, %%mm0 \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"movd %%mm0, %%eax \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"loop l_%= \n\t" \
     )

// if you move mmx ops closer then clock count increases by 1 for every nop skipped
TEST(test302c, \
	"l_%=: \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"movd %%ecx, %%mm0 \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"pextrw $0, %%mm0, %%eax \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"loop l_%= \n\t" \
     )

// if you move mmx ops closer then clock count increases by 1 for every nop skipped
TEST(test302d, \
	"l_%=: \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"pinsrw $0, %%ecx, %%mm0 \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"pextrw $0, %%mm0, %%eax \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"loop l_%= \n\t" \
     )

// if you move mmx ops closer then clock count increases by 1 for every nop skipped
TEST(test302e, \
	"l_%=: \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"movd %%ecx, %%mm0 \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"movd %%ecx, %%mm4 \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"movd %%mm0, %%eax \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"loop l_%= \n\t" \
     )

// if you move mmx ops closer then clock count increases by 1 for every nop skipped
TEST(test302f, \
	"l_%=: \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"pinsrw $0, %%ecx, %%mm0 \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"pinsrw $0, %%ecx, %%mm1 \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"pextrw $0, %%mm0, %%eax \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"loop l_%= \n\t" \
     )

// if you move mmx ops closer then clock count increases by 1 for every nop skipped
// "paddb %%mm1, %%mm2" can be moved freely up
TEST(test302g, \
	"l_%=: \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"pinsrw $0, %%ecx, %%mm0 \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"paddb %%mm1, %%mm2 \n\t" \
	"pextrw $0, %%mm0, %%eax \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"loop l_%= \n\t" \
     )

// if you move mmx ops closer then clock count increases by 1 for every nop skipped
// "paddb %%mm1, %%mm0" can be moved freely up
TEST(test302h, \
	"l_%=: \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"pinsrw $0, %%ecx, %%mm0 \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"paddb %%mm1, %%mm0 \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"pextrw $0, %%mm0, %%eax \n\t" \
	"nop \n\t" \
	"loop l_%= \n\t" \
     )

// if you move mmx ops closer then clock count increases by 1 for every nop skipped
TEST(test302i, \
	"l_%=: \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"paddb %%mm0, %%mm0 \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"pinsrw $0, %%ecx, %%mm0 \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"pextrw $0, %%mm0, %%eax \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"loop l_%= \n\t" \
     )

// if you move mmx ops closer then clock count increases by 1 for every nop skipped
TEST(test302j, \
	"l_%=: \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"paddb %%mm1, %%mm1 \n\t" \
	"pinsrw $0, %%ecx, %%mm0 \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"pextrw $0, %%mm0, %%eax \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"loop l_%= \n\t" \
     )

// if you move mmx ops closer then clock count increases by 1 for every nop skipped
// actually, if you move "movl %%ecx, 8(%%esi)" down, then the first one increases by 2
// "movq %%mm0, 8(%%esi)" can be moved freely up
TEST(test304, \
	"l_%=: \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"movl %%ecx, 8(%%esi) \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"movq 8(%%esi), %%mm0 \n\t" \
	"nop \n\t" \
	"movq %%mm0, 8(%%esi) \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"movl 8(%%esi), %%eax \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"loop l_%= \n\t" \
     )
test301: 21.273078
test302a: 31.464305
test302b: 31.461300
test302c: 31.421427
test302d: 31.420016
test302e: 32.483190
test302f: 32.479968
test302g: 32.460422
test302h: 32.460540
test302i: 32.452225
test302j: 32.412279
test304: 26.394288
